package com.quad.innovators.salesease.controller.scan;

import com.quad.innovators.salesease.annotation.DataPermission;
import com.quad.innovators.salesease.annotation.FunctionPermission;
import com.quad.innovators.salesease.annotation.Log;
import com.quad.innovators.salesease.annotation.RepeatSubmit;
import com.quad.innovators.salesease.common.result.PageResultBean;
import com.quad.innovators.salesease.common.result.Result;
import com.quad.innovators.salesease.constants.SystemConstants;
import com.quad.innovators.salesease.enums.LogModuleEnum;
import com.quad.innovators.salesease.model.common.Option;
import com.quad.innovators.salesease.model.form.scan.ScanSettingForm;
import com.quad.innovators.salesease.model.form.tag.TagForm;
import com.quad.innovators.salesease.model.query.tag.TagQuery;
import com.quad.innovators.salesease.model.vo.tag.TagVO;
import com.quad.innovators.salesease.service.scan.ScanSettingService;
import com.quad.innovators.salesease.service.tag.TagService;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author : shanshan.li
 * @createTime : 2025/4/15 10:17
 * @Version : 1.0 
 */
@Tag(name = "17.扫码设置")
@RestController
@RequestMapping(SystemConstants.BACKEND_API + "/scan-setting")
@RequiredArgsConstructor
@Slf4j
public class ScanSettingController {

    private final ScanSettingService scanSettingService;

    @Operation(summary = "获取设置列表")
    @GetMapping("")
    public Result<List<ScanSettingForm>> getList() {
        List<ScanSettingForm> result = scanSettingService.getList();
        return Result.success(result);
    }

    @Operation(summary = "新增")
    @PostMapping
    @RepeatSubmit
    public Result<?> save(@RequestBody @Valid ScanSettingForm form) {
        return Result.success(scanSettingService.save(form));
    }

    @Operation(summary = "删除")
    @DeleteMapping(value = "/{code}")
    @Parameters({
            @Parameter(name = "code", description = "code")
    })
    public Result<?> update(@PathVariable("code") String code) {
        return Result.success(scanSettingService.remove(code));
    }
}
